﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class playerc : MonoBehaviour
{
    public Rigidbody rbody;
    private int ccount = 0;
    // Start is called before the first frame update
    void Start()
    {
        rbody = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        Vector3 dir = new Vector3(h, 0, v);
        if (dir != Vector3.zero) {
            rbody.velocity = 3 * dir.normalized;
        }
        else
            rbody.velocity = Vector3.zero;
    }
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.collider.tag == "wall") {
            Debug.Log("wall, failed!");
            Time.timeScale = 0;
        }
    }
    public void addcoin() {
        ccount = ccount + 1;
        if (ccount >= 5) {
            Debug.Log("win");
            Time.timeScale = 0;
        }
    }
}
